package com.gang.mars.basic.generictype.demo3;

/**
 * 1,
 * @author gang.chen
 * @description 泛型类定义使用
 * @Date 2021/7/14 12:17
 */
public class AppleTest07 {

    public static void main(String[] args) {
        //泛型类的使用，型参为String
        Apple07<String> apple07 = new Apple07<>();
        apple07.setT("gang.chen");
        System.out.println(apple07.getT());

        //泛型类使用，型参为Integer
        Apple07<Integer> apple071= new Apple07<>();
        apple071.setT(1);
        System.out.println(apple071.getT());

        /*
         *结论
         * 1）泛型类在不指定型参时，默认为Object
         * 2）泛型类不支持基础数据类型，int,float...
         * 3）泛型的实例是多个，都向了一个Class类
         * */
        Apple07 apple072 = new Apple07();
        apple072.setT(100);
        apple072.setT("gang.chen");

        System.out.println(apple07.getClass());
        System.out.println(apple071.getClass());

        System.out.println(apple07.getClass() == apple071.getClass());

        System.out.println(apple07);
        System.out.println(apple071);

    }
}
